package chen.web.stat.keyword;

public class UrlAnalyserFactory {
	
	private static Scope[] scopes = new Scope[]{new GoogleUrlAnalyser(), new BaiduUrlAnalyser(), new SosoUrlAnalyser(), new SogouUrlAnalyser(), new GoogleUrlAnalyser2(), new BingUrlAnalyser(), new YahooUrlAnalyser()};
	
	public static UrlAnalysable getUrlAnalyser(String url){
		for(Scope scope : scopes){
			if(scope.inScope(url)){
				return scope.instance(url);
			}
		}
		return null;
	}
	

	public static void main(String[] args){
		System.out.println("google:" + getUrlAnalyser("http://www.google.com.hk/#hl=zh-CN&source=hp&biw=1280&bih=860&q=%E8%A6%81%E5%9C%B0&btnG=Google+%E6%90%9C%E7%B4%A2&aq=f&aqi=&aql=&oq=%E8%A6%81%E5%9C%B0&fp=529fef93cd91d35").keyword());
		System.out.println("baidu:" +getUrlAnalyser("http://www.baidu.com/s?bs=%D2%AA%B5%D8&f=8&wd=%CB%D5%D6%DD%CC%EC%C6%F8").keyword());
		System.out.println("sogou:" + getUrlAnalyser("http://www.sogou.com/web?query=%CE%D2&_asf=www.sogou.com&_ast=1302097832&w=01019900&p=40040100").keyword());
		System.out.println("soso:" + getUrlAnalyser("http://www.soso.com/q?pid=s.idx&w=%D2%AA%D4%DA").keyword());
		System.out.println("google.com:" + getUrlAnalyser("http://www.google.com/#sclient=psy&hl=en&q=facebook&aq=f&aqi=&aql=&oq=&pbx=1&bav=on.2,or.r_gc.r_pw.&fp=9d3468ca0635b6d").keyword());
		System.out.println("yahoo:" + getUrlAnalyser("http://search.cn.yahoo.com/search?v=web&ei=utf-8&searchFlag=&fr=fp-tab-web-ycn&pid=ysearch&source=yahoo_yhp_0706_search_button&p=我在").keyword());
		System.out.println("bing:" + getUrlAnalyser("http://cn.bing.com/search?q=%E8%A6%81%E5%9C%B0&go=&form=QBLH&qs=n&sk=&sc=2-2").keyword());
	}
}
